﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace ExcelExportLib
{
    [XmlRoot("Comment")]
    public class ExcelCellComment : IXmlSerializable
    {
        public List<ExcelCellCommentLine> lines = new List<ExcelCellCommentLine>();

        public ExcelCellComment() { }

        public ExcelCellComment(string commentText)
        {
            lines.Add(new ExcelCellCommentLine(commentText));
        }

        public void AddLine(string commentLine)
        {
            lines.Add(new ExcelCellCommentLine(commentLine));
        }

        public void AddLine(ExcelCellCommentLine commentLine)
        {
            lines.Add(commentLine);
        }

        #region IXmlSerializable Members

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            throw new NotImplementedException();
        }

        public void ReadXml(System.Xml.XmlReader reader)
        {
            throw new NotImplementedException();
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("ss:Data");

            //writer.WriteAttributeString("ss","Data",null, null);
            writer.WriteAttributeString("xmlns", null, null, "http://www.w3.org/TR/REC-html40");
            for (int i = 0; i < lines.Count; i++)
            {
                writer.WriteRaw(lines[i].ToString());
                if (i+1!=lines.Count)
                    writer.WriteRaw("&#10;");
            }
            writer.WriteEndElement();
        }

        #endregion
    }
}
